/**
 * 
 */
package com.holystone.orca.sys.service.impl;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.holystone.orca.base.service.impl.BaseServiceImpl;
import com.holystone.orca.sys.mybatis.dao.SysPrivilegeRoleMapper;
import com.holystone.orca.sys.mybatis.model.SysPrivilegeRole;
import com.holystone.orca.sys.service.ISysPrivilegeRoleService;


@Service(value="privilegeRoleService")
@Transactional
public class SysPrivilegeRoleServiceImpl extends BaseServiceImpl<SysPrivilegeRole> implements ISysPrivilegeRoleService {
	@Autowired
	private SysPrivilegeRoleMapper sysPrivilegeRoleMapper;

	@Override
	public boolean delPrivilegeRoleByRoleId(int roleId) throws Exception{
		List<SysPrivilegeRole> list = sysPrivilegeRoleMapper.selectPrivilegeByRoleId(roleId);
		if(list.isEmpty()){
			return true;
		}else{
			int result=sysPrivilegeRoleMapper.delPrivilegeRoleByRoleId(roleId);
			if(result >= 0){
				return true;
			}else{
				return false;
			}
		}
		
	}

	@Override
	public boolean addPrilegeRole(SysPrivilegeRole sysPrivilegeRole) throws Exception{
		int result=sysPrivilegeRoleMapper.addPrilegeRole(sysPrivilegeRole);
		if(result==1){
			return true;
		}else{
			return false;
		}
	}

	@Override
	public List<SysPrivilegeRole> selectPrivilegeRoleByRoleId(int roleId)
			{
		List<SysPrivilegeRole> privilegeRoleList=sysPrivilegeRoleMapper.selectPrivilegeByRoleId(roleId);
		return privilegeRoleList;
	}

	@Override
	public boolean delSelectPrilegeRole(List<Integer> list) throws Exception {
			int result=sysPrivilegeRoleMapper.delSelectPrilegeRole(list);
			if(result>=0){
				return true;
			}else{
				return false;
			}
	}

	@Override
	public String findActionPri(Integer roleId,String url) {
		SysPrivilegeRole pr = sysPrivilegeRoleMapper.findActionPri(roleId, url);
		if(pr==null||pr.getActionPri()==null){
			return "";
		}else{
			return pr.getActionPri();
		}
	}


	
}
